#include "mytime0.h"
#include <iostream>

Time::Time()
{
    hours = minutes = 0;
}

Time::Time(int h, int m)
{
    hours = h;
    minutes = m;
}

void Time::AddMin(int m)
{
    minutes += m;
    hours += m / 60;
    minutes %= 60;
}

void Time::AddHr(int h)
{
    hours += h;
}

void Time::Reset(int h, int m)
{
    minutes = m;
    hours = h;
}

Time Time::Sum(const Time & t) const
{
    Time res;
    res.hours = hours + t.hours;
    res.minutes = minutes + t.minutes;

    res.hours += res.minutes / 60;
    res.minutes = res.minutes % 60;

    return res;
}

void Time::Show() const
{   
    std::cout << hours << " - " << minutes << std::endl;
}

Time Time::operator+(const Time & t) const
{
    Time res;
    res.minutes = minutes + t.minutes;
    res.hours = hours + t.hours + res.minutes / 60;
    res.minutes = res.minutes % 60;

    return res;
}

Time Time::operator*(double m) const
{
    Time result;
    
    long totalminutes = hours * m * 60 + minutes * m;

    result.hours = totalminutes / 60;
    result.minutes = totalminutes % 60;
    return result;
}

std::ostream & operator<<(std::ostream & os, const Time t)
{
    os << t.hours << " H, " << t.minutes << " Min";
    return os;
}



